package com.financing.platform.dao.impl;


import java.sql.SQLException;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.financing.platform.dao.IAdvertDao;
import com.financing.platform.dto.AdvertDTO;
import com.financing.platform.dto.PublicActivitiesDTO;
import com.financing.platform.util.SqlName;
import com.financing.platform.vo.PublicActivitiesVO;

@Repository("advertDaoImpl")
public class AdvertDaoImpl extends BaseDaoImpl  implements IAdvertDao {

	public int addPublicActivites(PublicActivitiesDTO publicActivitiesDTO)
			throws SQLException {
		return (Integer) this.sqlMapClient.insert(SqlName.addPublicActivities, publicActivitiesDTO);
	}

	@SuppressWarnings("unchecked")
	public List<PublicActivitiesVO> publicActivitiesList() throws SQLException {
		return this.sqlMapClient.queryForList(SqlName.publicActivitiesList);
	}

	public PublicActivitiesDTO queryPublicActivities(
			PublicActivitiesDTO publicActivitiesDTO) throws SQLException {
		return (PublicActivitiesDTO) this.sqlMapClient.queryForObject(SqlName.queryAdvert, publicActivitiesDTO);
	}

	public int updatePublicActivities(PublicActivitiesDTO publicActivitiesDTO)
			throws SQLException {
		return this.sqlMapClient.update(SqlName.updatePublicActivities,publicActivitiesDTO);
	}

	@Override
	public int addAdvert(AdvertDTO advertDTO) throws SQLException {
		return (Integer) this.sqlMapClient.insert(SqlName.addAdvert, advertDTO);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<AdvertDTO> queryAdvertList(AdvertDTO advertDTO)
			throws SQLException {
		return this.sqlMapClient.queryForList(SqlName.queryAdvert,advertDTO);
	}

	@Override
	public AdvertDTO queryAdvertInfo(Integer id) throws SQLException {
		return (AdvertDTO) this.sqlMapClient.queryForObject(SqlName.queryAdvertInfo, id);
	}

	@Override
	public int updateAdvert(AdvertDTO advertDTO) throws SQLException {
		return this.sqlMapClient.update(SqlName.updateAdvert,advertDTO);
	}

	@Override
	public int queryAdvertListCount(AdvertDTO advertDTO) throws SQLException {
		return (Integer)this.sqlMapClient.queryForObject(SqlName.queryAdvertCount, advertDTO);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<AdvertDTO> queryAdvertRecommendList(AdvertDTO advertDTO)
			throws SQLException {
		return this.sqlMapClient.queryForList(SqlName.queryAdvertRecommend,advertDTO);
	}
	
	@Override
	public int queryAdvertListRecommendCount(AdvertDTO advertDTO) throws SQLException {
		return (Integer)this.sqlMapClient.queryForObject(SqlName.queryAdvertCount, advertDTO);
	}
}
